package xin.clips.web.controller.socket;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {
    public static void main(String[] args) throws IOException {
        //1、创建服务器端的Socket对象(ServerSocket)
        ServerSocket ss = new ServerSocket(9527);
        //Socket accept()侦听要连接到此套接字并接受它
        Socket s = ss.accept();

        while(true){
            //2、获取输入流，读数据，并把数据显示在控制台
            InputStream is = s.getInputStream();
            byte[] bys = new byte[1024];
            int len = is.read(bys);
            String data = new String(bys,0,len);
            System.out.println("数据是："+data);
        }

    }
}